﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Telecom.Service;
using TelecomGis.Helper.Control;

namespace TelecomGis.Controllers
{
    public class DaunoiTBController : ContronllerBase
    {
        private readonly vnptSiteSer _vnptSiteSer = new vnptSiteSer();

        public ActionResult DaunoiTB()
        {
            return PartialView("_DaunoiTB");
        }

        public string List_VNPT_DAU_NOI(string donviQl, string ToQL, string TramVT)
        {

            string[] toqlCode;
            string[] _donviql;

            if (string.IsNullOrEmpty(ToQL)) toqlCode = UtContextgis._UserPageContext.ToKtByuser;
            else { List<string> _listtoql = new List<string>(); _listtoql.Add(ToQL); toqlCode = _listtoql.ToArray(); }

            if (string.IsNullOrEmpty(donviQl)) _donviql = UtContextgis._UserPageContext.DonViByUser;
            else { List<string> _listdonvlql = new List<string>(); _listdonvlql.Add(donviQl); _donviql = _listdonvlql.ToArray(); }

            var _listEntity = _vnptSiteSer.getListOnDVTOQLTRAMVT(toqlCode, _donviql, TramVT);

            return JsonConvert.SerializeObject(_listEntity, Formatting.Indented,
                              new JsonSerializerSettings
                              {
                                  ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                              });
        }

    }
}
